<template>
  <div>
    <van-search v-model="value" shape='round' placeholder="请输入搜索关键词" />
    <div class="cfy">
      <div class="left">
        <van-sidebar v-model="id">
          <van-sidebar-item v-for="(item,index) in listArr" @click="dian(index)" :key="item.id" :title="item.name" />
        </van-sidebar>
      </div>
      <div class="right">
        <div>
          <img :src="listObj.banner_url">
          <van-grid :column-num="3">
            <van-grid-item v-for="item in listObj.subCategoryList" :key="item.id" :icon="item.wap_banner_url" :text="item.name" />
          </van-grid>
        </div>
      </div>
    </div>

  </div>
</template>

<script>

// 导入axios请求
import  { getClassData } from "@/https/http";
import  { getClassListData } from "@/https/http";

export default {
    data(){
      return{
        value:'',
        id:0,
        listArr:[],
        listObj:{}
      }
    },

    methods:{
      dian(index){
        let id = this.listArr[index].id
        getClassListData({id}).then(res=>{
          this.listObj = res.data.data.currentCategory
          console.log(11,this.listObj);
          console.log(res);
          })
      }
    },
    mounted(){
      getClassData().then(res=>{
        this.listArr = res.data.data.categoryList
        console.log(this.listArr);
          getClassListData({id:this.listArr[0].id}).then(res=>{
            this.listObj = res.data.data.currentCategory
            console.log(11,this.listObj);
            console.log(22,res);
            })
      })
     
    },

}
</script>

<style scoped lang='less'>
  .cfy{
    display: flex;
    flex: 1;
    .right{
      img{
        margin-left: 7px;
        width: 95%;
      }
    }
  }
</style>